package _11_二叉树的前中后非递归遍历;

import _05_树.printer.BinaryTrees;
import _11_二叉树的前中后非递归遍历.tree.BST;
import _11_二叉树的前中后非递归遍历.tree.BinaryTree;
import org.junit.Test;

public class Main {
    @Test
    public void testPerOrder(){
        Integer[] nums = {6,4,7,2,5,1,3};
        BST<Integer> bst = new BST<>();

        for (Integer num : nums) {
            bst.add(num);
        }
        BinaryTrees.println(bst);
        bst.preOrder(new BinaryTree.Visitor<Integer>() {
            @Override
            public boolean visit(Integer element) {
                System.out.print(element+" ");
                return false;
            }
        });
    }

    @Test
    public void testInOrder(){
        Integer[] nums = {6,4,7,2,5,1,3};
        BST<Integer> bst = new BST<>();

        for (Integer num : nums) {
            bst.add(num);
        }
        BinaryTrees.println(bst);
        bst.inOrder(new BinaryTree.Visitor<Integer>() {
            @Override
            public boolean visit(Integer element) {
                System.out.print(element+" ");
                return false;
            }
        });
    }

    @Test
    public void testPostOrder(){
        Integer[] nums = {6,4,7,2,5,1,3};
        BST<Integer> bst = new BST<>();

        for (Integer num : nums) {
            bst.add(num);
        }
        BinaryTrees.println(bst);
        bst.postOrder(new BinaryTree.Visitor<Integer>() {
            @Override
            public boolean visit(Integer element) {
                System.out.print(element+" ");
                return false;
            }
        });
    }
}
